import util from "@/libs/util";
import router from "@/router";

export default {
  install(Vue) {
    // 跳转店铺详情页面
    Vue.prototype.toShopPage = function (id) {
      router.push({ path: "/shop/details/" + id });
    };
    // 跳转商品详情页面
    Vue.prototype.toGoodsPage = function (id) {
      router.push({ path: "/goods/details/" + id });
    };
    // 跳转订单详情页面
    Vue.prototype.toOrderDetail = function (order) {
      router.push({
        path: "/order/details/",
        query: { order: JSON.stringify(order) },
      });
    };
    // 跳转订单详情页面
    Vue.prototype.addOrderSaleafter = function (num) {
      router.push({
        path: "/order/saleafter/" + num,
      });
    };
    // 跳转订单详情页面
    Vue.prototype.toOrderDetailId = function (id) {
      router.push({ path: "/order/details/" + id });
    };
    // 跳转到登录页面
    Vue.prototype.toLogin = util.toLogin;
    // 跳转购物车页面
    Vue.prototype.toCartPage = () => {
      router.push({ path: "/car/index/" });
    };

    Vue.prototype.loadingMsg = function (message = "加载中...") {
      let loading = this.$message({
        iconClass: "el-icon-loading",
        duration: 0,
        customClass: "loading-message",
        message,
      });
      return loading;
    };
  },
};
